package se.webbzon.boltzmann.player;

import java.util.ArrayList;
import java.util.List;

import se.webbzon.boltzmann.battle.battleaction.BattleActionFactory;
import se.webbzon.boltzmann.game.character.AbstractCharacter;
import se.webbzon.boltzmann.game.character.AbstractCharacterTextureSet;
import se.webbzon.boltzmann.game.character.CharacterException;
import se.webbzon.boltzmann.game.object.player.AbstractPlayerCharacter;

public abstract class PlayerCharacter {
	
	// The name of the character
	private final String name;
	
	// The name of the character texture set associated with this character
	private final String characterTextureSetName;
	
	// A list of all the available battle action factories for this character
	private final List<BattleActionFactory> factories;

	/*============================================================
	Constructors
	============================================================*/
	
	protected PlayerCharacter(	String name, 
								String characterTextureSetName) {
		this.name = name;
		this.characterTextureSetName = characterTextureSetName;
		
		factories = new ArrayList<BattleActionFactory>();
	}
	
	/*============================================================
	Public Methods
	============================================================*/
	
	/** Creates a new player character instance. **/
	public abstract AbstractPlayerCharacter makePlayerCharacter(Player player) throws CharacterException;
	
	/** Returns the name of the character. **/
	public String getName() {
		return name;
	}
	
	/** Returns the name of character texture set associated 
	 * with this character. **/
	public String getCharacterTextureSetName() {
		return characterTextureSetName;
	}
	
	/** Returns the character texture set associated with this character. **/
	public AbstractCharacterTextureSet getCharacterTextureSet() {
		return AbstractCharacter.getCharacterTextureSetMap().get(characterTextureSetName);
	}
	
	/** Returns the number of available battle action factories
	 * for this character. **/
	public int battleActionFactories() {
		return factories.size();
	}
	
	/** Returns the (n+1):th battle action factory for this character. **/
	public BattleActionFactory getBattleActionFactory(int n) {
		return factories.get(n);
	}
	
	/** Adds a battle action factory to this character. **/
	public boolean addBattleActionFactory(BattleActionFactory factory) {
		return factories.add(factory);
	}
	
	/** Removes a battle action factory from this character. **/
	public boolean removeBattleActionFactory(BattleActionFactory factory) {
		return factories.remove(factory);
	}
	
	/** Clears all the battle action factories for this character. **/
	public void clearBattleActionFactories() {
		factories.clear();
	}
	
}
